package cn.shengchao.rule.condition.matchType;

import cn.hutool.core.util.StrUtil;
import cn.shengchao.rule.condition.valueType.ArrayValueType;
import cn.shengchao.rule.condition.valueType.IValueType;

import java.util.List;

/**
 * @program: examstarapi
 * @description: 数组映射操作
 * @author: Xiong weiqiang
 * @create: 2025-04-12 20:28
 */
public class MatchTypeInArray implements IMatchType{
    @Override
    public String getMatchTypeKey() {
        return IMatchType.IN_ARRAY;
    }

    @Override
    public String getMatchTypeValue() {
        return "数组";
    }

    @Override
    public boolean isMatch(String targetValue, String matchValue, IValueType valueType) {
        if (StrUtil.isBlank(matchValue)){
            return true;
        }else if (StrUtil.isNotBlank(targetValue)){
            List<String> matchList = ArrayValueType.parseValueToList(matchValue);
            return matchList.contains(targetValue);
        }
        return false;
    }
}